﻿using System;

using NUnit.Framework;

namespace Yawf.Core.Utils {
	[TestFixture]
	public class DateUtilsTest {
		[Test]
		public void TestParseDate() {
			DateTime tmpDate;

			tmpDate = DateUtils.ParseDate(null,"01/01/1970");
			Assert.AreEqual(DateTime.MinValue,tmpDate,"ParseDate(null,'01/01/1970') not equal to DateTime.MinValue");
			tmpDate = DateUtils.ParseDate("dd'/'MM'/'yyyy",null);
			Assert.AreEqual(DateTime.MinValue,tmpDate,"ParseDate(dd/MM/yyyy,null) not equal to DateTime.MinValue");
			tmpDate = DateUtils.ParseDate("dd'/'MM'/'yyyy HH:mm:ss","01/01/1970 12:03:03");
			Assert.AreEqual(1,tmpDate.Day,"ParseDate(dd/MM/yyyy,01/01/1970 12:03:03).Day not equal to 1");
			Assert.AreEqual(1,tmpDate.Month,"ParseDate(dd/MM/yyyy,01/01/1970 12:03:03).Month not equal to 1");
			Assert.AreEqual(1970,tmpDate.Year,"ParseDate(dd/MM/yyyy,01/01/1970 12:03:03).Year not equal to 1970");
			Assert.AreEqual(12,tmpDate.Hour,"ParseDate(dd/MM/yyyy,01/01/1970 12:03:03).Hour not equal to 12");
			Assert.AreEqual(3,tmpDate.Minute,"ParseDate(dd/MM/yyyy,01/01/1970 12:03:03).Minute not equal to 3");
			Assert.AreEqual(3,tmpDate.Second,"ParseDate(dd/MM/yyyy,01/01/1970 12:03:03).Second not equal to 3");
		}
	}
}
